import React, { Component } from "react";

class index extends Component {

  checkAll = (e) => {
    this.props.checkAll(e.target.checked);
  };

  render() {
    let num = 0;
    this.props.data.forEach((item) => {
      if (item.done) {
        num++;
      }
    });
    return (
      <div>
        {
          <input
            type="checkbox"
            checked={num === this.props.data.length}
            onChange={this.checkAll}
          />
        }
        已完成：{num}/{this.props.data.length}
      </div>
    );
  }
}

export default index;
